package com.report.service;

import com.report.dto.Response;
import com.report.entity.ReportTemplate;
import com.report.entity.TableRowMapping;
import com.report.repository.TableRowMappingRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TableRowMappingService {

    @Resource
    private TableRowMappingRepository tableRowMapping;


    public Response records(TableRowMapping request) {
        List<TableRowMapping> tableRowMappingByProjectNo = tableRowMapping.getTableRowMappingByProjectNo(request.getProjectNo());

        Response response = new Response();
        response.setStatus("success");
        response.setMessage("success");
        response.setData(tableRowMappingByProjectNo);
        return response;
    }

    public Response insert(TableRowMapping request) {
        tableRowMapping.upsert(request);
        Response response = new Response();
        response.setStatus("success");
        response.setMessage("success");
        return response;
    }

    public Response delete(TableRowMapping request) {
        tableRowMapping.deleteById(request.getId());
        Response response = new Response();
        response.setStatus("success");
        response.setMessage("success");
        return response;
    }
}
